<template>
  <view class="container">
    <view class="header">
    <!-- <view class="left">
        <text class="close-icon">×</text>
      </view> -->
      <!-- <view class="title" >
        1
      </view> -->
     <!-- <view class="right">
        <text class="menu-icon">···</text>
      </view> -->
    </view>

    <view class="content">
      <image class="illustration" src="/static/images/client/shoper/商家首页图.png"></image>
      <view class="welcome-text">
        欢迎光临
      </view>
      <view class="company-name">
        卡丘网络科技有限公司
      </view>
	  <textarea id="textToCopy" readonly style="position: absolute; opacity: 0; z-index: -1;">
	  儿的作品11111111111/</textarea>
      <button class="buy-button" @click="buyNow">
        我要买单
      </button>
    </view>
  </view>
</template>

<script>
	import {listTraderManager} from '@/api/system/traderManager.js'
	import {listOriginalQRcodeshowPay} from '@/api/system/originalQRcode.js'
export default {
	onLoad(options) {
		console.log(options.traderId);
		if(options.traderId){
			// 获取抖音链接
			listTraderManager({traderNumber:options.traderId}).then(res=>{
				this.douyinLink = res.rows[0].douyinLink
				
				
			})
			// 获取原码信息
			var queryParams={
				traderNumber:options.traderId
			}
			listOriginalQRcodeshowPay(queryParams).then(res=>{
				this.OriginalQRcode = res.rows[0]
				this.originalQrCodeLink = this.OriginalQRcode.originalQrCodeLink
				console.log(JSON.stringify(this.OriginalQRcode))
		
				
			})
			
		}
	},
	data() {
		return {
			traderManager: {},
			OriginalQRcode: {},
			originalQrCodeLink:'',
			douyinLink:'',
			
			
			
		}
	},
  methods: {
	 
		copyToClipboard() {
			// 先隐藏任何现有的提示
			uni.hideToast();
			if(this.douyinLink){
				const text = this.douyinLink;
				uni.hideToast();
				uni.setClipboardData({
				  data: text,
				  
				});
				uni.hideToast();
			}
		     
		    
		
    },
    buyNow() {
		uni.hideToast();
		// window.location.reload();
		this.copyToClipboard()
     
	  if(this.originalQrCodeLink){
		  
		
		window.location.href = this.originalQrCodeLink;


	  }else{
		  window.location.reload();
	  }
	   
    }
  }
}
</script>

<style scoped>
.container {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100vh;
  background-color: #f5f5f5;
}
.header {
  display: flex;
  justify-content: center; /* 将justify-content改为center */
  align-items: center;
  padding: 0 15px;
  height: 60px;
  background-color: #f5f5f5;
}

.close-icon, .menu-icon {
  font-size: 20px;
}
.title {
  font-size: 18px;
  font-weight: bold;
  text-align: center; /* 添加这一行，确保文本居中 */
  flex: 1; /* 使标题占据可用的空间 */
  
}

.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.illustration {
  width: 200px;
  height: 200px;
  margin-bottom: 30px;
}

.welcome-text {
  font-size: 24px;
  font-weight: bold;
  margin-bottom: 10px;
}

.company-name {
  font-size: 16px;
  margin-bottom: 30px;
}

.buy-button {
  width: 80%;
  height: 50px;
  background-color: #1E90FF;
  color: white;
  border-radius: 25px;
  font-size: 18px;
  text-align: center;
  line-height: 50px;
}
</style>
